home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / sound / players / noisetra.s < prev    next >
Text File  |  1995-04-22  |  27KB  |  1,615 lines

  1. *************************************************
  2. * This NoiseTracker source is made by:        *
  3. * Lars-Åke Berg                    *
  4. * Email adress:d0berg@dtek.chalmers.se        *
  5. * It is PublicDomain                *
  6. * If you want to get in contact with me        *
  7. * use my email adress or write to        *
  8. * Lars-Åke Berg                    *
  9. * Volratamsgatan 6-9320                *
  10. * 412 60 Göteborg                *
  11. * Sweden                    *
  12. * or phone 046-(0)31-163123            *
  13. *************************************************
  14. * Thanx to M.K for the sorce.(from the Amiga)    *
  15. *************************************************
  16. * This player uses NoiseTracker modules from    *
  17. * the amiga (not SoundTracker and ProTracker).    *
  18. * To start, it,do like this.            *
  19. * 1. Assamble it in (Seka).            *
  20. * 2. Chose playing frek by puting 0,1 or 2(.l)    *
  21. *    in hz (label).                *
  22. * 3. jump to start.                *
  23. * 4. to stop playing jump to back.        *
  24. * 3 diffrent playing frek. are included.    *
  25. * The flag hz(.l) stands for            *
  26. * 0(.l)=6.25 kHz 1(.l)=12.5 kHz 2(.l)=25.0 kHz    *
  27. * don't forget to do initmusic and initdma     *
  28. * after changing playing frek.            *
  29. *************************************************
  30. moduldta=$80000
  31. start:
  32.     bsr.L    mod_init
  33.     bsr.l     initmusic
  34.     bsr.l     initdma
  35.     move.w    #$2700,sr
  36.     move.l    $70,oldvbl
  37.     move.l    #vbl,$70
  38.     move.w    #$2300,sr
  39.     rts
  40. back:
  41.     move.w    #$2700,sr
  42.     move.l    oldvbl,$70
  43. ;    move.w    #$-1,$ff8240
  44.     move.w    #$2300,sr
  45.     rts
  46. oldvbl:    dc.l 0
  47. vbl:
  48.     movem.l    a0-a6/d0-d7,-(sp)
  49.     
  50. ;    move.w     #$000,$ff8240
  51.     bsr.L    playmod
  52.     move.w     #$fff,$ff8240
  53.     bsr.l    Atari_rutin
  54. ;    move.w    #$-1,$ff8240
  55.  
  56.     bsr.s    levelstaplar
  57.     movem.l    (sp)+,a0-a6/d0-d7
  58.     rte
  59. ***********************************************
  60. ;show rutiner
  61. ***********************************************
  62. levelstaplar:
  63.     lea    voice1+6,a1
  64.     lea    old_voltab,a2
  65.     move.w (a1),d0    ;level ch 0
  66.     move.w 28(a1),d1;level ch 1
  67.     move.w 56(a1),d2;level ch 2
  68.     move.w 84(a1),d3;level ch 3
  69.     and.w #$7f,d0
  70.     and.w #$7f,d1
  71.     and.w #$7f,d2
  72.     and.w #$7f,d3
  73.     lsr.w #1,d0    ;skala ner 2 ggr.
  74.     lsr.w #1,d1
  75.     lsr.w #1,d2
  76.     lsr.w #1,d3
  77.     
  78.     lea    $f8002+[160*90],a0
  79.     bsr.s    vol_before
  80.     bsr.s     channel
  81.         
  82.     lea     $f800a+[160*90],a0
  83.     move.w     d1,d0
  84.     bsr.s    vol_before
  85.     bsr.s     channel
  86.  
  87.     lea     $f8012+[160*90],a0
  88.     move.w     d2,d0
  89.     bsr.s    vol_before
  90.     bsr.s     channel
  91.  
  92.     lea     $f801a+[160*90],a0
  93.     move.w     d3,d0
  94.     bsr.s    vol_before
  95.     bsr.s     channel
  96.     rts
  97. vol_before:
  98.     cmp.w    #$40,d0
  99.     ble.s    no_error_vol
  100.     moveq    #$40,d0
  101. no_error_vol:
  102.     move.w    (a2),d5
  103.     cmp.w    d5,d0
  104.     blo.s    minska_st
  105.     move.w    d0,(a2)+
  106.     rts
  107. minska_st:
  108.     subq.w    #1,d5
  109.     bpl.s    minska_st2
  110.     moveq    #0,d5
  111. minska_st2:
  112.     move.w    d5,(a2)+
  113.     move.w    d5,d0
  114.     rts
  115. channel:
  116.     lea stapel,a1
  117.     lsl.w #1,d0
  118.     and.l #$00fe ,d0
  119.     add.l d0,a1
  120.     moveq #31,d4
  121. lpstap:
  122.     move.w (a1)+,(a0)
  123.     lea 160(a0),a0
  124.     dbf d4,lpstap
  125.     rts
  126. old_voltab:
  127.     dc.w 0,0,0,0
  128. stapel:
  129.     dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  130.     dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  131.     dc.w -1,-1,-1,-1,-1,-1,-1,-1
  132.     dc.w -1,-1,-1,-1,-1,-1,-1,-1
  133.     dc.w -1,-1,-1,-1,-1,-1,-1,-1
  134.     dc.w -1,-1,-1,-1,-1,-1,-1,-1
  135. ************************************************
  136. mod_init:
  137. ;spara pekare till smp data.
  138.     lea     moduldta,a0
  139.     lea     spl_dta_starts,a1
  140.  
  141.     lea    42(a0),a0    
  142.     moveq     #31,d0        ;max 31 sampels.
  143.     moveq    #$1e,d1
  144. init_lp:
  145.     move.l    a0,(a1)+
  146.     add.l    d1,a0
  147.     dbf    d0,init_lp
  148. ;leta reda pa hogsta pattern nr. ->d2    
  149.     lea    moduldta,a0    
  150.     lea    952(a0),a0
  151.     moveq    #127,d0        ;max 128
  152.     moveq    #0,d1
  153.     moveq    #0,d2
  154. init_lp2:
  155.     move.b    (a0)+,d1
  156.     cmp.b    d2,d1
  157.     ble.s    init_lp3
  158.     move.w d1,d2
  159. init_lp3:
  160.     dbf    d0,init_lp2
  161.     addq.l    #1,d2        ;step    to spl.
  162. ;find samples starts
  163.     lea    moduldta,a0
  164.     lea    1084(a0),a0    ;pattern starts        
  165.     lea    spl_starts,a1
  166.     lea    spl_dta_starts,a2
  167.     lsl.l    #8,d2        ;mulu 1024
  168.     lsl.l    #2,d2        ;step to first spl.
  169.     add.l    d2,a0        ;pointer spl.
  170.     moveq    #31,d1
  171. init_lp4:
  172.     moveq    #0,d0
  173.     move.l    a0,(a1)+
  174.     move.l    (a2)+,a3
  175.     move.w    (a3),d0        ;len in words
  176.     lsl.w    #1,d0        ;in bytes
  177.     add.l    d0,a0
  178.     dbf    d1,init_lp4
  179. ;set volym =0
  180.     lea    voice1,a0
  181.     moveq    #0,d0
  182.     move.w    d0,6(a0)
  183.     move.w    d0,28+6(a0)
  184.     move.w    d0,56+6(a0)
  185.     move.w    d0,84+6(a0)
  186.     move.b    d0,songpos
  187.     move.b    d0,counter
  188.     move.w    d0,patternpos
  189.     move.b    #6,songspeed
  190.     rts
  191. ;init data.
  192. spl_dta_starts:    blk.l    32,0
  193. spl_starts:    blk.l    32,0
  194. songpos:    dc.b    0
  195. counter:    dc.b    0
  196. patternpos:    dc.w    0
  197. songspeed:    dc.b    0
  198. mod_break:    dc.b    0
  199. even
  200. playmod:
  201.     lea    moduldta,a0
  202.     add.b    #1,counter
  203.     move.b    counter,d0
  204.     cmp.b    songspeed,d0
  205.     blo.L    no_new
  206. new_voice:
  207.     moveq    #0,d0
  208.     moveq    #0,d1
  209.     lea    1084(a0),a1    ;first pattern pek
  210.     move.b    d0,counter
  211.     move.b    songpos,d0
  212.     add.l    #950,a0
  213.     move.b    2(a0,d0.w),d0
  214.     move.w    patternpos,d1
  215.     lsl.l    #8,d0        ;find right pattern offset.
  216.     lsl.l    #2,d0    
  217.  
  218.     lea    spl_starts,a2
  219.     lea    spl_dta_starts,a6
  220.     lea    voice1,a4
  221.     bsr.s    playvoice
  222.     addq.w    #4,d1
  223.     lea    voice2,a4
  224.     bsr.s    playvoice
  225.     addq.w    #4,d1
  226.     lea    voice3,a4
  227.     bsr.s    playvoice
  228.     addq.w    #4,d1
  229.     lea    voice4,a4
  230.     bsr.s    playvoice
  231.     addq.w    #4,d1
  232.     move.w d1,patternpos
  233.     
  234.     cmp.w    #1024,d1
  235.     bne.s    not_end_pattern
  236. end_pattern:
  237.     move.w    #0,patternpos
  238.     clr.b    mod_break
  239.     add.b    #1,songpos
  240.     move.b    songpos,d0
  241.     cmp.b    (a0),d0        
  242.     bne.s    not_end_song
  243. end_song:
  244.     move.b    #0,songpos
  245.     move.w    #0,patternpos
  246. not_end_pattern:
  247. not_end_song:
  248.     tst.b    mod_break
  249.     bne.s    end_pattern
  250.     rts
  251. playvoice:
  252.     lea 0(a1,d0.l),a3    ;pattern pek    
  253.     add.l    d1,a3        ;pattern pos
  254.     move.l    (a3),18(a4)    ;lagra ton dta.
  255.  
  256.     moveq    #0,d2
  257.     moveq    #0,d3
  258.     move.w    18(a4),d2
  259.     move.w    18+2(a4),d3
  260.     and.w    #$f000,d2
  261.     and.w     #$f000,d3
  262.     lsr.w    #4,d3
  263.     or.w    d3,d2
  264.     lsr.w    #8,d2
  265.     tst.w    d2
  266.     beq.L    old_instr
  267.  
  268.     sub.w    #1,d2
  269.     lsl.w    #2,d2
  270.     move.l    0(a2,d2.w),a5    ;spl start
  271.     move.l    a5,(a4)        ;to voicedta
  272.     move.l    a5,d3        ;copy spl start
  273.     
  274.     move.l    0(a6,d2.w),a5    ;spl dta pek
  275.     move.w    (a5),d2
  276.     
  277.     lsl.w    #1,d2        ;len in bytes
  278.     neg.w    d2
  279.     sub.l    d2,(a4)        ;andra  spl start
  280.     move.w    d2,4(a4)    ;to voicedta
  281.     move.w    2(a5),d2    
  282.     and.w    #$007f,d2    ;volyme (mask bort fine tune)
  283.     
  284.     cmp.w    #$40,d2
  285.     ble.s    volmask
  286.     moveq    #$40,d2
  287. volmask:
  288.     move.w    d2,6(a4)    ;volym
  289.  
  290.     moveq    #0,d2
  291.     move.w    4(a5),d2    ;rep point
  292.     beq.s    no_loop        ;no rep from beginning
  293.  
  294.     lsl.w    #1,d2        ;to bytes.
  295.     add.l    d3,d2        
  296.     move.l    d2,8(a4)    ;rep start
  297.     moveq    #0,d4    
  298.     move.w    6(a5),d4    ;rel len
  299.     lsl.w    #1,d4        ;rep len in bytes
  300.     neg.w    d4
  301.     sub.l    d4,8(a4)    ;rep start.
  302.     move.w    d4,12(a4)    ;rep dta pek. (len)
  303.     bra.s    looping    
  304. no_loop:    
  305.     move.l    d3,8(a4)        
  306.     moveq    #0,d3
  307.     move.w    6(a5),d3
  308.     sub.w    #1,d3        ;kompensation
  309.     lsl.w    #1,d3
  310.     neg.w    d3
  311.     sub.l    d3,8(a4)
  312.     move.w    d3,12(a4)
  313. looping:
  314.     move.w    #0,16(a4)
  315. old_instr:
  316.     move.w    18(a4),d2
  317.     and.w    #$0fff,d2    ;note period
  318.     beq.L    mod_command2
  319.     tst.w    4(a4)        ;tst spl len
  320.     beq.s    stopsound
  321.  
  322.     move.b    18+2(a4),d3    ;effect command
  323.     and.b    #$0f,d3
  324.     cmp.b    #5,d3
  325.     beq.s    set_port
  326.     cmp.b    #3,d3
  327.     beq.s    set_port
  328.  
  329.     move.w    d2,14(a4)    ;to voicedta
  330.     clr.b    27(a4)
  331.     bra.L    mod_command2
  332. stopsound:
  333.     move.w    #0,6(a4)
  334.     bra.L    mod_command2
  335. no_new:
  336.     lea    voice1,a4
  337.     bsr.L    mod_command
  338.     lea    voice2,a4
  339.     bsr.L    mod_command
  340.     lea    voice3,a4
  341.     bsr.L    mod_command
  342.     lea    voice4,a4
  343.     bsr.L    mod_command
  344.     rts
  345. set_port:
  346.     move.w    18(a4),d2        ;period
  347.     and.w    #$0fff,d2
  348.     move.w    d2,22(a4)    ;new period?
  349.     move.w    14(a4),d3    ;old note period
  350.     clr.b    24(a4)
  351.     cmp.w    d3,d2
  352.     beq.s    mod_clrport
  353.     bge.L    mod_command2
  354.     move.b    #1,24(a4)        ;set flag
  355.     bra.L    mod_command2
  356. mod_clrport:
  357.     clr.w    22(a4)
  358.     rts    
  359. mod_port:
  360.     moveq    #0,d3
  361.     move.b    18+3(a4),d2
  362.     beq.s    mod_port2
  363.     move.b    d2,25(a4)
  364.     move.b    d3,18+3(a4)
  365. mod_port2:
  366.     tst.w    22(a4)
  367.     beq.s    mod_rts
  368.     move.b    25(a4),d3
  369.     tst.b    24(a4)
  370.     bne.s    mod_sub
  371.     add.w    d3,14(a4)
  372.     move.w    22(a4),d3
  373.     cmp.w    14(a4),d3
  374.     bgt.s    mod_portok
  375.     move.w    22(a4),14(a4)
  376.     clr.w    22(a4)
  377. mod_portok:
  378. mod_rts:
  379.     rts
  380. mod_sub:
  381.     sub.w    d3,14(a4)
  382.     move.w    22(a4),d3
  383.     cmp.w    14(a4),d3
  384.     blt.s    mod_portok
  385.     move.w    22(a4),14(a4)
  386.     clr.w    22(a4)
  387.     rts
  388. mod_sin:
  389.     dc.b $00,$18,$31,$4a,$61,$78,$8d,$a1
  390.     dc.b $b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
  391.     dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5
  392.     dc.b $b4,$a1,$8d,$78,$61,$4a,$31,$18
  393.  
  394. mod_vib:
  395.     move.b 18+3(a4),d3
  396.     beq.s    mod_vib2
  397.     move.b    d3,26(a4)
  398. mod_vib2:
  399.     move.b    27(a4),d3
  400.     lsr.w    #2,d3
  401.     and.w    #$1f,d3
  402.     moveq    #0,d2
  403.     lea    mod_sin,a3
  404.     move.b    0(a3,d3.w),d2
  405.     move.b    26(a4),d3
  406.     and.w    #$0f,d3
  407.     mulu     d3,d2
  408.     lsr.w    #7,d2
  409.     move.w    14(a4),d3
  410.     tst.b    27(a4)
  411.     bmi.s    mod_vibsub
  412.     add.w    d2,d3
  413.     bra.s    mod_vib3
  414. m